using System;
using System.Collections.Generic;
using System.Text;

namespace Acms.DataControls
{
    public class SelectEventArgs<Item> : EventArgs
    {
        internal SelectEventArgs(System.Web.UI.DataSourceSelectArguments arguments)
            : base()
        {
            this.maximumRecords = arguments.MaximumRows;
            this.retrieveTotalRowCount = arguments.RetrieveTotalRowCount;
            this.sortExpression = arguments.SortExpression;
            this.startRowIndex = arguments.StartRowIndex;
        }

        private ICollection<Item> data;
        internal ICollection<Item> GetData()
        {
            return data;
        }

        public void SetData(ICollection<Item> data, int totalRecords)
        {
            this.data = data;
            this.totalRecords = totalRecords;
        }

        public void SetData(ICollection<Item> data)
        {
            this.data = data;
            totalRecords = data.Count;
        }

        public void SetData(Item data)
        {
            if (data != null)
            {
                this.data = new Item[] { data };
                totalRecords = 1;
            }
            else
            {
                this.data = new Item[0];
                totalRecords = 0;
            }
        }

        private int totalRecords = -1;
        public int TotalRecords
        {
            get { return totalRecords; }
        }

        private int maximumRecords;
        public int MaximumRecords
        {
            get { return maximumRecords; }
        }

        private bool retrieveTotalRowCount;
        public bool RetrieveTotalRowCount
        {
            get { return retrieveTotalRowCount; }
        }

        private string sortExpression;
        public string SortExpression
        {
            get { return sortExpression; }
        }

        private int startRowIndex;
        public int StartRowIndex
        {
            get { return startRowIndex; }
        }
	
    }
}
